﻿"""测试单选框"""
import tkinter as tk
from tkinter import messagebox
from PIL import Image, ImageTk
import random


class Application(tk.Frame):  # Application是应用的含义，需要继承Frame的初始化
    """一个经典的GUI程序的类的写法"""

    def __init__(self, master=None):  # 要传递master
        super().__init__(master)
        self.master = master
        self.pack()  # 通过布局管理显示
        self.create_widget()  # 调用类函数进行初始化小部件

    def create_widget(self):  # Widget是小部件的含义
        """通过grid布局实现登录界面"""
        self.user_name_label = tk.Label(self, text='用户名')
        self.user_name_label.grid(row=0, column=0)
        self.user_name_entry = tk.Entry(self)
        self.user_name_entry.grid(row=0, column=1)
        tk.Label(self, text='用户名为手机号').grid(row=0, column=2)
        tk.Label(self, text='密码').grid(row=1, column=0)
        tk.Entry(self, show='*').grid(row=1, column=1)
        tk.Button(self, text='登录').grid(row=2, column=1, sticky=tk.EW)
        tk.Button(self, text='取消').grid(row=2, column=2, sticky=tk.E)





def main():
    root = tk.Tk()
    root.geometry("800x500+200+300")
    root.title("测试label标签")
    app = Application(master=root)
    root.mainloop()


if __name__ == '__main__':
    main()
